<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

let obj = new EventTarget();
// 添加事件
obj.addEventListener("myevent",function(){
    console.log("fn1")
})
obj.addEventListener("myevent",function(){
    console.log("fn2")
})

// 触发
setTimeout(()=>{
    // trigger(eventName)
    obj.dispatchEvent(new CustomEvent("myevent"))
},1000)

</script>
</html>